import { Injectable } from '@nestjs/common';
import NodeAuth from 'simp-node-auth';
import * as uuidv4 from 'uuid';
import { UserService } from '@src/modules/system/user/services/user.service';

@Injectable()
export class ToolsService {
  private nodeAuth: NodeAuth;
  constructor(private readonly userService: UserService) {
    this.nodeAuth = new NodeAuth();
  }

  /**
   * @description: 密码加密
   */
  makePassword(password: string): string {
    return this.nodeAuth.makePassword(password);
  }

  /**
   * @description: 校验密码
   * sqlPassword: 加密后的密码
   */
  checkPassword(password: string, sqlPassword: string): boolean {
    return this.nodeAuth.checkPassword(password, sqlPassword);
  }

  /**
   * @description: 生成token
   */
  public get uuidToken(): string {
    return uuidv4.v4();
  }
}
